import {get, post, del, put} from "@/api/base/http";
import {ApiUri} from "@/api/base/ApiPath";

let ApiPath = new ApiUri();

export class Project {

    /**
     * 获取所有项目
     * @constructor
     */
    static Gets = () => {
        return get(ApiPath.Project.LIST);
    }

    /**
     * 获取单个项目
     * @param Id
     * @constructor
     */
    static Get = <T = any>(Id: Number) => {
        return get(ApiPath.Project.ROOT + Id);
    }

    /**
     * 发布项目
     * @param Id
     * @param callback
     * @constructor
     */
    static ReleasedById = <T = any>(Id: string) => {
        return post(ApiPath.Project.RELEASED + Id)
            .then(res => res.data);
    }

    /**
     * 删除项目
     * @param Id
     * @constructor
     */

    static Delete = <T = any>(Id: Number) => {
        return del(ApiPath.Project.ROOT + Id);
    }

    static Update = (Project: any) => {
        return put(ApiPath.Project.ROOT, Project);
    }

    static Add(Project: any) {
        return post(ApiPath.Project.ROOT, Project);
    }

    static CopyProject(ProjectId: number) {
        return post(ApiPath.Project.COPY_PROJECT + ProjectId);
    }
}
